﻿using Model;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Service
{
    public class UserService
    {
        //创建EF大管家
        Model1 db = new Model1();

        //注册
        public bool register(CMS_User u)
        {
                //添加操作
                db.Entry(u).State = EntityState.Added;
                //不参与添加的字段
                db.Entry(u).Property(x => x.uid).IsModified = false;
                db.Entry(u).Property(x => x.nname).IsModified = false;
                db.Entry(u).Property(x => x.face).IsModified = false;
                db.Entry(u).Property(x => x.admin).IsModified = false;
                //提交事务
                db.SaveChanges();
                //添加成功
                return true;
        }

        //销毁EF大管家
        public void Dispose()
        {
            db.Dispose();
        }
    }
}
